<template>
  <div class="home">
      <el-space>
        <el-space>
          <div>付款时间</div>
          <el-date-picker
              v-model="params.beginTime"
              type="date"
              placeholder=""
              value-format="YYYY-MM-DD"
          />
          <div>-</div>
          <el-date-picker
              v-model="params.endTime"
              type="date"
              placeholder=""
              value-format="YYYY-MM-DD"
          />
        </el-space>

        <el-space>
          <div>站点</div>
          <el-select
              v-model="params.siteId"
              style="width: 200px"
          >
            <el-option
                v-for="item in sitesOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
            />
          </el-select>
        </el-space>

        <el-space>
          <div>店铺</div>
          <el-select
              v-model="params.storeId"
              style="width: 200px"
          >
            <el-option
                v-for="item in storeOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
            />
          </el-select>
        </el-space>

        <el-button type="success" @click="getList">查询</el-button>
      </el-space>

    <div>
      <ul class="bulletinBoard">
        <li v-for="item in listData" class="flex-c">
          <div>
            <span class="title">{{ item.title }}</span>
            <span class="num">{{ item.data }}</span>
          </div>
        </li>
      </ul>
    </div>
    <div class="box"  v-for="item in dataList" :key="item">
      <div class="box_title">{{item.siteName}}</div>
      <div class="box_main">
        <div>
          <h1>订单量</h1>
          <h2>{{item.counts}}</h2>
        </div>
        <div>
          <h1>总营业额</h1>
          <h2>{{item.salePrice}}</h2>
        </div>
        <div>
          <h1>总利润</h1>
          <h2>{{item.totalProfit}}</h2>

        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import {onMounted, onActivated, ref, reactive, getCurrentInstance} from "vue";
import { useStore } from "vuex";
import BulletinBoard from "./component/bulletinBoard.vue";
import { ElMessageBox, ElMessage } from "element-plus";
const { proxy } = getCurrentInstance();
const params = reactive({
  beginTime:'',
  endTime:'',
  siteId:'',
  storeId:''
})
const sitesOption = ref([])
const storeOption = ref([])

const  dataList  = ref([])

const listData = ref([
  {
    title: '浏览量',
    data: '-',
  },
  {
    title: '总订单',
    data: '-',
  },
  {
    title: '总营业额',
    data: '-',
  },
  {
    title: '总利润',
    data: '-',
  },
])
function  getSite(){
  const params = {keyword:'',regionId:'',pageNo:1,pageSize:1000}
  proxy.$http.get('/jx/jxSiteManage/querySitesByRegionOrKeyword', { params: params,}).then(res => {
    sitesOption.value.push(...res?.result.sites.map(item=>{
      return {
        label : item.siteName,
        value: item.siteId
      }
    }))
  })
}

function  getStore(){
  const params = {keyword:"",pageNo:1,pageSize:1000}
  proxy.$http.get('/jx/jxStoreManage/queryStoreByKeyword', { params }).then(res => {
    storeOption.value.push(...res?.result.stores.map(item=>{
      return {
        label : item.storeName,
        value: item.id
      }
    }))
  })
}

function  getList(){
  proxy.$http.post('/jx/jxOrderManage/platformDate', params ).then(({result:res}) => {
    console.log(res)
    listData.value[0].data  = res.countUser
    listData.value[1].data =  res.Platform.counts
    listData.value[2].data =  res.Platform.salePrice
    listData.value[3].data =  res.Platform.price
    dataList.value = res.site
  })
}


onMounted(()=>{
  getSite()
  getStore()
  getList()
})


</script>
<style lang="scss" scoped>
.home {
  
}
.box{
  width: 80%;
  height: 159px;
  margin: 10px auto;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 0 8px #00000026;
}
.box_title{
  color: #000000;
  padding-left: 15px;
  padding-top: 15px;
  font-weight: bold;
  font-size: 24px;
}
.box_main{
  margin-top: 20px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  >div{
    display: flex;
    flex-flow: column;
    height: 80px;
    justify-content: space-around;
    align-items: center;
  }
}

</style>
<style lang="scss" scoped>
.bulletinBoard {
  display: flex;
  justify-content: space-evenly;
  flex-wrap: wrap;
  color: #fff;
  margin-top: 100px;
  li {
    width: 280px;
    height: 180px;
    margin: 5px 0px;
    cursor: pointer;
    border-radius: 4px;
    transition-duration: .3s;
    &:hover {
      transform: scale(1.03);
    }
    &:nth-child(1) {
      background-color: #3cdb86;
    }
    &:nth-child(2) {
      background-color: #4480f4;
    }
    &:nth-child(3) {
      background-color: #083045;
    }
    &:nth-child(4) {
      background-color: #f66932;
    }
    &:nth-child(5) {
      background-color: #04ebe0;
    }
    span {
      display: block;
      text-align: center;
    }
    span:nth-child(1) {
      margin-bottom: 16px;
    }
  }
  .num {
    font-size: 46px;
  }
}

@media screen and (max-width : 1370px) and (min-width: 1060px) {
  .bulletinBoard {
    justify-content: space-between;
  }
}

</style>
